package gameComponents;
import gamePieces.Bishop;
import gamePieces.King;
import gamePieces.Knight;
import gamePieces.Pawn;
import gamePieces.Piece;
import gamePieces.Queen;
import gamePieces.Rook;

import java.awt.Point;
import java.io.IOException;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;


/**
 * Game Engine for Chess. Ontop of the move restrictions implemented in the Piece classes,
 * this class contains more restrictions which are specific to the game of Chess.
 * 
 */
public class ChessGame extends SuperGame{
	
	private Player player1; // WHITE PIECES
	private Player player2; // BLACK PIECES
	private Player currentPlayer;
	private Board board;
	private static HashMap<String, ArrayList<Piece>> piecesBlack;
	private static HashMap<String, ArrayList<Piece>> piecesWhite;
	private Scanner in;
	
	/**
	 * Constructor for ChessGame object. Default initializes to 2 players, with respective ids
	 * of 1 and 2.
	 * @author Sabrina Gaudreau, Vivian Andreeva
	 */
	public ChessGame() {
		this.board = new Board();
		this.in = new Scanner(System.in);
		this.player1 = new Player(1);
		this.player2 = new Player(2); // passing an Id of 2 provides lower case representation in toString()
		this.currentPlayer = player1; // Player 1 starts
	}
	
	/**
	 * Main method. Runs the Chess game.
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		ChessGame g = new ChessGame();
		g.play();
	}
	
	/**
	 * Runs through a Chess Game Scenario with the user.
	 * 
	 * @author Sabrina Gaudreau, Vivian Andreeva
	 * @throws IOException 
	 * @modified by Selman Selman, Jordan Beland
	 */
	public void play() throws IOException{
		addPlayer1Pieces();
		addPlayer2Pieces();
		placeOnBoard(player1);
		placeOnBoard(player2);
		board.print();
		int p = 1;
		
		System.out.println("$$$ Chess Game $$$");
		System.out.println("Press 'q' at anytime to quit the game! :) Enjoy");
		//String s = "gameisnotlost"; // just until checkmate works :) // obsolete.
		//int a = 1; it is never used?
		while(!checkMate()){
			if (currentPlayer == player1){
				p = 1;
			}
			else if (currentPlayer == player2){
				p = 2;
			}
			System.out.println("Its Player" + p + "'s Turn!");
			if(check())System.out.println("Current Player is in check!"); // remove!
			System.out.println("Please enter the position of the piece to move:");
			String initPos = in.nextLine();
			if(initPos == "q"){
				break;
			}
			int x = Board.convertX(initPos);
			int y = Board.convertY(initPos);
			if(board.getBoard()[x][y] != null){//new 
				if(checkSamePiece(x,y)){ // checks if piece at that coordinate is yours or not
					System.out.println("Enter the position where you would like to move the piece");
					String finalPos = in.nextLine();
					if(finalPos == "q"){
						break;
					}
					int newX = Board.convertX(finalPos);
					int newY = Board.convertY(finalPos);
			
					Piece currentPiece = getPiece(x,y);
					if(currentPiece instanceof Pawn){
						movePawn(newX,newY,currentPiece);
					}
					else if(currentPiece instanceof Queen || currentPiece instanceof Rook ||currentPiece instanceof Bishop){
						moveBRQ(newX,newY,currentPiece);
					}
					else if(currentPiece instanceof Knight){
						moveKnight(newX, newY, currentPiece);
					}
					else if(currentPiece instanceof King){
						moveKing(newX, newY, currentPiece);
					}
				}else{
					System.out.println("There is no piece at that position or that piece does not belong to you");					
				}
		}else{
			System.out.println("There is no piece at that position or that piece does not belong to you");
		}
			placeOnBoard(player1);
			placeOnBoard(player2);
			board.print();
			
	}
		System.out.println("Player " + currentPlayer.getId() + " has been mated. Game over.");
	}
	
	/**
	 * Sets up all the coordinates of Player 2's pieces
	 * @author Sabrina Gaudreau, Vivian Andreeva
	 */
	public void addPlayer1Pieces() {
		piecesWhite = player1.returnMap();
		
		// Add King piece to player
		piecesWhite.get("K").add(new King(3,7, player1));
		
		// Add Queen piece to player
		piecesWhite.get("Q").add(new Queen(4,7, player1));
		
		// Add Bishop pieces to player
		piecesWhite.get("B").add(new Bishop(2,7, player1));
		piecesWhite.get("B").add(new Bishop(5,7, player1));
		
		// Add Knight pieces to player
		piecesWhite.get("N").add(new Knight(1,7, player1));
		piecesWhite.get("N").add(new Knight(6,7, player1));
		
		// Add Rook pieces to player
		piecesWhite.get("R").add(new Rook(0,7, player1));
		piecesWhite.get("R").add(new Rook(7,7, player1));
		
		 //Add eight pawns to the player
		for (int j = 0; j <8; j++) {
			piecesWhite.get("P").add(new Pawn(j,6, player1));
		}
	}
	
	/**
	 * Sets up all the coordinates of Player 2's pieces
	 * @author Sabrina Gaudreau, Vivian Andreeva
	 */
	public void addPlayer2Pieces() {
		piecesBlack = player2.returnMap();
		
		// Add King piece to player
		piecesBlack.get("K").add(new King(3,0, player2));
		
		// Add Queen piece to player
		piecesBlack.get("Q").add(new Queen(4,0, player2));
		
		// Add Bishop pieces to player
		piecesBlack.get("B").add(new Bishop(2,0, player2));
		piecesBlack.get("B").add(new Bishop(5,0, player2));
		
		// Add Knight pieces to player
		piecesBlack.get("N").add(new Knight(1,0, player2));
		piecesBlack.get("N").add(new Knight(6,0, player2));
		
		// Add Rook pieces to player
		piecesBlack.get("R").add(new Rook(0,0, player2));
		piecesBlack.get("R").add(new Rook(7,0, player2));
		
		//Add eight pawns to the player
		for (int j = 0; j <8; j++) {
			piecesBlack.get("P").add(new Pawn(j,1, player2));
		}
	}
	
	/**
	 * Places the player's pieces onto the board at their 
	 * specified coordinates.
	 * 
	 * @author Sabrina Gaudreau, Vivian Andreeva
	 */
	@SuppressWarnings("unchecked")
	public void placeOnBoard(Player player) {
		// Gets hashmap from player 1, its values, and converts the 6 arraylists into 
		// 1 array object.
		Object[] a1 = player.returnMap().values().toArray();
		ArrayList<Piece> p1 = new ArrayList<Piece>();
		
		for (int i = 0; i<6; i++) {
			if (p1 instanceof ArrayList) {
				p1 = (ArrayList<Piece>) a1[i]; // not fully checked, but the only Collection the ArrayList will ever be of, is Piece.
			} else {
				break;
			}
			
			for (Piece p: p1) {
				board.placePiece(p.getX(), p.getY(), p.toString(), player);
			}
		}
	}
	
	
	/**
	 * Returns the piece object located on the board at the given
	 * x and y coordinates. If not Piece is presents, returns null.
	 * 	
	 * @param x
	 * @param y
	 * @return The piece object at the requested coordinates.
	 */
	@SuppressWarnings("unchecked")
	public Piece getPiece(int x, int y){
			if (board.getBoard()[x][y] == null){
				return null;
			}
			else{
				Object[] a = currentPlayer.returnMap().values().toArray();
				ArrayList<Piece> p = new ArrayList<Piece>();
				
				for (int i = 0; i<6; i++) {
					if (p instanceof ArrayList) {
						p = (ArrayList<Piece>) a[i]; // will always be an ArrayList of Piece.
					} else {
						break;
					}
					for (Piece pp: p) {
						if(pp.getY() == y && pp.getX() == x){
							return pp;
						}
					}
				}
			}
			return null;
	}
	
	/**
	 * Checks to make sure the pawn can move where it wants to go and moves it.
	 * @param x coordinate of new location
	 * @param y coordinate of new location
	 * @param the Pawn piece to move
	 * @author - Sabrina Gaudreau
	 * @modified by Selman Selman and Jordan Beland
	 */
	public void movePawn(int newX, int newY, Piece piece){
		//if(piece instanceof Pawn){
			Pawn P = (Pawn)piece;
			int x = P.getX();// for use in overwriting old place on board
			int y = P.getY();// for use in overwriting old place on board
		//}
		if(P.checkIfLegal(newX, newY)){
			if(currentPlayer == player1){
				//wants to move 1 up
				if(P.getY() - 1 == newY && board.getBoard()[newX][newY] == null && P.getX() == newX){// check if a piece is already in the location
					board.placePiece(x, y, "", currentPlayer);//overwrites old position on board
					removePiece(newX, newY);
					P.move(newX, newY);
					switchPlayer();//new
					//P.setY(newY);
				}
				//wants to move 2 up (only availabe if first move)
				else if(P.getY() - 2 == newY && P.getY() == 6 && !P.hasMoved() && board.getBoard()[newX][newY] == null && P.getX() == newX){//check if a piece is already in location, and pawn has not moved
					board.placePiece(x, y, "", currentPlayer);//overwrites old position on board
					removePiece(newX, newY);
					P.move(newX, newY);
					switchPlayer(); //new
					//P.setY(newY);
				}
				//wants to move right up (only availabe if a piece of the opposite player is there)
				else if(checkSamePiece(newX, newY) != true && board.getBoard()[newX][newY] != null && P.getY() - 1 == newY && P.getX() + 1 == newX){
					board.placePiece(x, y, "", currentPlayer);//overwrites old position on board
					removePiece(newX, newY);
					P.move(newX, newY);
					switchPlayer(); //new
					//P.setY(newY);
					//P.setX(newX);
				}
				//wants to move left up (only availabe if a piece of the opposite player is there)
				else if(checkSamePiece(newX, newY) != true && board.getBoard()[newX][newY] != null && P.getY() - 1 == newY && P.getX() - 1 == newX){
					board.placePiece(x, y, "", currentPlayer);//overwrites old position on board
					removePiece(newX, newY);
					P.move(newX, newY);
					switchPlayer();//new
				}
			}
			if(currentPlayer == player2){
				//wants to move 1 down
				if(P.getY() + 1 == newY && board.getBoard()[newX][newY] == null && P.getX() == newX){// check if a piece is already in the location
					board.placePiece(x, y, "", currentPlayer); //new //overwrites old position on board
					removePiece(newX, newY);
					P.move(newX, newY);
					switchPlayer();//new
				}
				//wants to move 2 down (only availabe if first move)
				else if(P.getY() + 2 == newY && P.getY() == 1 && !P.hasMoved() && board.getBoard()[newX][newY] == null && P.getX() == newX){// check if a piece is already in the location and pawn has not moved
					board.placePiece(x, y, "", currentPlayer); //new //overwrites old position on board
					removePiece(newX, newY);
					P.move(newX, newY);
					switchPlayer();//new
				}
				//wants to move right down (only availabe if a piece of the opposite player is there)
				else if(checkSamePiece(newX, newY) != true && board.getBoard()[newX][newY] != null && P.getY() + 1 == newY && P.getX() - 1 == newX){
					board.placePiece(x, y, "", currentPlayer); //new //overwrites old position on board
					removePiece(newX, newY);
					P.move(newX, newY);
					switchPlayer();//new
				}
				//wants to move left down (only availabe if a piece of the opposite player is there)
				else if(checkSamePiece(newX, newY) != true && board.getBoard()[newX][newY] != null && P.getY() + 1 == newY && P.getX() + 1 == newX){
					board.placePiece(x, y, "", currentPlayer); //new //overwrites old position on board
					removePiece(newX, newY);
					P.move(newX, newY);
					switchPlayer();//new
				}
			}
	}else{
		System.out.println("**** Move is invalid, please try again! ****"); //new
	}
	//board.placePiece(oldX, oldY, "", currentPlayer); // I moved this up to only evaluate when a move was done.
	}
	
	
	/**
	 * The move method for the Bishop, Rook, and Queen.
	 * @param x coordinate of new location
	 * @param y coordinate of new location
	 * @param the Bishop, Rook, or Queen object to move.
	 * @author Jordan Beland
	 * @modified by Selman Selman
	 */
	public void moveBRQ(int newX, int newY,Piece piece){
			int x = piece.getX();// for use in overwriting old place on board
			int y = piece.getY();// for use in overwriting old place on board
			if(piece.checkIfLegal(newX, newY)){
				if(!checkSamePiece(newX, newY)){
					if(!(pieceBetween(x, y, newX, newY))){
						board.placePiece(x, y, "", currentPlayer); //new //overwrites old position on board
						removePiece(newX, newY);
						if(piece instanceof Bishop){
							Bishop b = (Bishop)piece;
							b.move(newX, newY);
							board.getBoard()[newX][newY] = b;
						}
						else if(piece instanceof Rook){
							Rook r = (Rook)piece;
							r.move(newX, newY);
							board.getBoard()[newX][newY] = r;
						}
						else if(piece instanceof Queen){
							Queen q = (Queen)piece;
							q.move(newX, newY);
							board.getBoard()[newX][newY] = q;
						}
							
						switchPlayer();//new
					}
				}
			} else{
				System.out.println("**** Move is invalid please try again! ****");//new
			}
	}
	
	/**
	 * Move method for the Knight
	 * @param Knight object to move
	 * @param x coordinate of new location
	 * @param y coordinate of new location
	 * @author Jordan Beland
	 * @modified by Selman Selman
	 */
	public void moveKnight(int newX, int newY,Piece piece){
		int x = piece.getX(); // for use in overwriting old place on board
		int y = piece.getY();// for use in overwiting old place on board
		if(piece instanceof Knight){
			Knight k = (Knight)piece;
		if(k.checkIfLegal(newX, newY)){
			if(!checkSamePiece(newX, newY)){
				board.placePiece(x, y, "", currentPlayer); //new //overwrites old position on board
				removePiece(newX, newY);
				piece.move(newX, newY);
				board.getBoard()[newX][newY] = k;
				switchPlayer();//new
			}
			
		} else{
			System.out.println("**** Move is invalid please try again! ****");//new
		}
	}
	}
	

	
	/**
	 * Move Method for the king
	 * @param King object to move
	 * @param x coordinate of new location
	 * @param y coordinate of new location
	 * @author Jordan Beland
	 * @modified by Selman Selman
	 */
	public void moveKing(int newX, int newY,Piece piece){
		int x = piece.getX();
		int y = piece.getY();
		if(piece instanceof King){
			King k = (King)piece;
		if(k.checkIfLegal(newX, newY)){
			if(!checkSamePiece(newX, newY)){
				if((willBeInCheck(newX, newY))){
					System.out.println("Invalid move, King would be in Check!"); // remove when creating GUI.
				}else{
				board.placePiece(x, y, "", currentPlayer); //new clears old position on board
				removePiece(newX, newY); // removes any piece from the future position from the board and its hashmap
				piece.move(newX, newY); // sets the new x and y of the piece moved
				board.getBoard()[newX][newY] = k; // places the piece on the board
				switchPlayer();//new
				}
			}
		} else {
			System.out.println("**** Move is invalid please try again! ****");//new
		}	
	}
	}
	
	/**
	 * Checks to see if the position where the player wants to move has a piece 
	 * that is from the same player.
	 * @return boolean (True if piece is from same player)
	 * @author - Sabrina Gaudreau
	 */
	public boolean checkSamePiece(int newX, int newY){
		int player;
		if(currentPlayer == player1){//used to be == player2?
			player = 1;
		}
		else{
			player = 2;
		}
		if(board.getBoard()[newX][newY] != null){
			if(board.getBoard()[newX][newY].getOwnership().getId() == player){
				return true; //cannot move there
			}
		}
		return false; //therefore user can move there if he wants (it is either empty or has the opposite player piece there
	}
	
	
	/**
	 * checks if there are any pieces inbetween destination point, and starting point.
	 * Does NOT check if piece is capable to move in such a fashion, does NOT check if
	 * new location contains a piece, does NOT check if move would put it off the board.
	 * 
	 * @param x
	 * @param y
	 * @param newX
	 * @param newY
	 * @return boolean true if a piece is in between
	 * @author Jordan Beland
	 */
	public boolean pieceBetween(int x, int y, int newX, int newY){
		int xDiff = newX - x;
		int yDiff = newY - y;
		//going right
		if(xDiff > 0 && yDiff == 0){
			int tempx = x;
			int tempy = y;
			while(tempx+1 < newX){
				if(board.getBoard()[tempx+1][tempy] != null)return true;
				tempx += 1;
			}
		}else if(xDiff <0 && yDiff == 0){ //going left
			int tempx = x;
			int tempy = y;
			while(tempx-1 > newX){
				if(board.getBoard()[tempx-1][tempy] != null)return true;
				tempx -= 1;
			}
		}else if(xDiff == 0 && yDiff >0){ //going down
			int tempx = x;
			int tempy = y;
			while(tempy+1 < newY){
				if(board.getBoard()[tempx][tempy+1] != null) return true;
				tempy += 1;
				}
		}else if(xDiff == 0 && yDiff <0){//going up
			int tempx = x;
			int tempy = y;
			while(tempy-1 > newY){
				if(board.getBoard()[tempx][tempy-1] != null)return true;
				tempy -= 1;
			}
		}else if(xDiff >0 && yDiff <0){//going up/right
			int tempx = x;
			int tempy = y;
			//the absolute difference of y and x will be the same on diagonals
			while(tempx+1 < newX && tempy-1 > newY){
				if(board.getBoard()[tempx+1][tempy-1] != null)return true;
				tempy -= 1;
				tempx += 1;
			}
		}else if(xDiff < 0 && yDiff < 0){//going up/left
			int tempx = x;
			int tempy = y;
			//the absolute difference of y and x will be the same on diagonals
			while(tempx-1 > newX && tempy-1 > newY){
				if(board.getBoard()[tempx-1][tempy-1] != null)return true;
				tempy -= 1;
				tempx -= 1;
			}
		}else if(xDiff < 0 && yDiff > 0){//going down/left
			int tempx = x;
			int tempy = y;
			//the absolute difference of y and x will be the same on diagonals
			while(tempx-1 > newX && tempy+1 < newY){
				if(board.getBoard()[tempx-1][tempy+1] != null)return true;
				tempy += 1;
				tempx -= 1;
			}
		}else if(xDiff > 0 && yDiff > 0){//going down/right
			int tempx = x;
			int tempy = y;
			//the absolute difference of y and x will be the same on diagonals
			while(tempx+1 < newX && tempy+1 < newY){
				if(board.getBoard()[tempx+1][tempy+1] != null)return true;
				tempy += 1;
				tempx += 1;
			}
		}
		return false;	
	}
	
	
	
	/**
	 * Returns an ArrayList of all the Points the opponent (not currentPlayer) can
	 * reach by moving a piece in the given board set up.
	 * 
	 * @return The opposing players moves
	 * @author - Vivian Andreeva
	 * @modified Jordan Beland
	 */
	public ArrayList<Point> getOpponentMoves() {
		ArrayList<Point> filter1 = new ArrayList<Point>();
		ArrayList<Point> filter2 = new ArrayList<Point>(); // maybe this should be a set, since we dont need duplicate coordinates?
		switchPlayer(); // Player is opponent
		// Gets hashmap from opponent player
		HashMap<String, ArrayList<Piece>> opponentPieces = currentPlayer.returnMap();
		Set<String> keys = opponentPieces.keySet();
		// For each element in HashMap (Each key)
		for (String k : keys){
			// ArrayList in each Key
			ArrayList<Piece> p = opponentPieces.get(k) ;
			// For each piece in arrayList of a Key
			for (Piece piece : p){
				ArrayList<Point> possMoves = piece.possibleMoves();
				for (Point p1 : possMoves) {
					if(piece instanceof Pawn){// pawns cant move straight ahead if there is a piece in the way
						if(piece.getX() == p1.x){ // moving straight ahead
							if(board.getBoard()[p1.x][p1.y] == null){//no piece straight ahead
								filter1.add(p1);
							}
						}
						else{// he is moving diagonally
							if (checkSamePiece(p1.x, p1.y) == false){// check if currentPlayer's piece is already in the location
								filter1.add(p1);
						}
					}
					}	
					else if (checkSamePiece(p1.x, p1.y) == false){// check if currentPlayer's piece is already in the location
						filter1.add(p1);
					}
				}
				for (Point p2 : filter1) {
					if (pieceBetween(piece.getX(), piece.getY(), p2.x, p2.y) == false) {// check if a piece is in the way
						filter2.add(p2);
					}
				}
				filter1.clear(); // clear filter1 for next piece
				}
			}
		// Returns to current player
		switchPlayer();
		return filter2;
	}
	/**
	 * Check check to see if the king can be eaten but there is still
	 * a possible move
	 * Checks if current player is in check. Should be called at the start of every turn.
	 * @return boolean (True if player's king is in check)
	 * @author - Vivian Andreeva
	 */
	public boolean check(){ // Player is current player.
		ArrayList<Point> filter2 = getOpponentMoves();
		Piece king = currentPlayer.returnMap().get("K").get(0);
		for (Point p3 : filter2) {
			if (p3.x == king.getX() && p3.y == king.getY()) {
				return true;
			}
		}
		return false;
	}
	
	/**
	 * Checks if the king would be in check if he were at the
	 * specified location. Used when moving the king, since
	 * the king cannot move into check.
	 * @param x coordinate of new location
	 * @param y coordinate of new location
	 * @return true if the move would put the king into check
	 * @author Jordan Beland
	 */
	public boolean willBeInCheck(int x, int y){
		Piece kingPointer = currentPlayer.returnMap().get("K").get(0); // save ref to king
		board.placePiece(kingPointer.getX(), kingPointer.getY(), "", currentPlayer); // temp remove king from the board
		ArrayList<Point> filter2 = getOpponentMoves(); // get opponents moves
		for(Point p3 : filter2){ // check all moves to see if the new spot is in check
			if(p3.x == x && p3.y == y){
				board.placePiece(kingPointer.getX(), kingPointer.getY(), "K", currentPlayer);// replace king
				return true;
			}
		}
		board.placePiece(kingPointer.getX(), kingPointer.getY(), "K", currentPlayer);// replace king
		return false;
	}
	
	/**
	 * Checks to see if there are no more possible moves for the king
	 * and it will end up being eaten by the opponent's piece. Does NOT check
	 * if other pieces can move to block the check, only checks if the king can
	 * move out of check.
	 * @return True if checkmate
	 * @author - Vivian Andreeva
	 * @modified Jordan Beland
	 */
	public boolean checkMate() {
		if(!check())return false;// if he is not currently in check, it can't be checkmate
		Piece king = currentPlayer.returnMap().get("K").get(0); // get the king
		ArrayList<Point> kingPosMoves = king.possibleMoves(); // get all of the kings possible moves
		ArrayList<Point> kingFiltered = new ArrayList<Point>();
		for(Point p1 : kingPosMoves){
			if(!checkSamePiece(p1.x, p1.y)){// check if the move would be blocked by his own player
				kingFiltered.add(p1); // if not, let it pass through
			}
		}
		for(Point p2 : kingFiltered){
			if(!willBeInCheck(p2.x, p2.y))return false; // if he won't be in check at that position, it's not checkmate
		}
		return true; // at this point, king is in check and every move will put him in check, therefore checkmate.
	}
		
	
	/**
	 * Removes a piece at the given x and y coordinates. Returns true if a 
	 * piece was removed, false if there was no piece there.
	 * To be called BEFORE the new piece is moved to the position
	 * because this method will remove the piece at given coordinates
	 * from the board and from its respective player's hashmap
	 * 
	 * @param x location of piece to remove
	 * @param y location of piece to remove
	 * @return true if a piece was removed
	 * @author Sabrina Gaudreau and Jordan Beland
	 * @modified Selman Selman
	 */
	public boolean removePiece(int x, int y){
		// get the piece at location
		Piece toRemove = board.getBoard()[x][y];
		// if there is no piece there, return false.
		if(toRemove == null){
			System.out.println("there was no piece there!");
			return false;
		}
		// get the player owner's hashmap
		HashMap<String, ArrayList<Piece>> pieces = toRemove.getOwnership().returnMap();
		// get all the keys in the map
		Set<String> keys = pieces.keySet();
		// loop through the keys and values until you find the piece toRemove
		for (String k : keys){
			ArrayList<Piece> ps = pieces.get(k); // gets the value (collection of pieces of the same type)
			for (Piece p : ps){//loop through each piece until you find toRemove
				if(p.getX() == toRemove.getX() && p.getY() == toRemove.getY()){ // check if the coordinates are the same, could be replaced later by a .equals()?
					board.getBoard()[p.getX()][p.getY()] = null; // clear space on board
					ps.remove(p); // remove piece from the list of pieces the player has
					System.out.println("piece was removed!!");
					break;
				}
			}
		}
		
		return true;
	}
	
	
	/**
	 * Switches current player to the other player
	 * @author Jordan Beland
	 */
	public void switchPlayer(){
		if(currentPlayer == player1){ //if currentPlayer is one, make it two
			currentPlayer = player2;
		}
		else{ //otherwise its player 2, so make it 1
			currentPlayer = player1;
		}
	}
	
	/**
	 * For testing purposes only!
	 * @return player1
	 * @author Vivian Andreeva
	 */
	public Player getPlayer1() {
		return player1;
	}
	
	/**
	 * For testing purposes only!
	 * @return player2
	 * @author Vivian Andreeva
	 */
	public Player getPlayer2() {
		return player2;
	}
	
	/**
	 * For testing purposes only!
	 * @return board
	 * @author Vivian Andreeva
	 */
	public Board getBoard() {
		return board;
	}
	
	/**
	 * For testing purposes only!
	 * @return current player
	 * @author Vivian Andreeva
	 */
	public Player getCurrentPlayer() {
		return currentPlayer;
	}
	

}


